package com.crm.dao.repositoryDAO;

import com.crm.pojo.Repository;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface RepositoryDAO extends CrudRepository<Repository,Long>, JpaSpecificationExecutor<Repository> {
    //查询所有未删除的仓库数量
    @Query(nativeQuery = true,value = "select count(*) from REPOSITORY r where r.REPOSITORY_IS_DEL='否'")
    public Long queryCount();

    //查询所有未删除的仓库 分页
    @Query("from Repository r where r.repositoryIsDel='否'")
    public List<Repository> allRepositoryPaged(Pageable pageable);
    //模糊查询仓库名称或仓库地址
    @Query("from Repository r where r.repositoryIsDel='否'and (r.rname like ?1 or r.raddress like ?1 )")
    public List<Repository> allRepositoryByMh(String q);
    //查询所有未删除的仓库 不分页
    @Query("from Repository r where r.repositoryIsDel='否'")
    public List<Repository> allRepository();
}
